home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacAddict 123
/
MacAddict_123_2006_11.iso
/
Software
/
Internet & Communication
/
Sandvox 1.0.4.dmg
/
Sandvox.app
/
Contents
/
Resources
/
documentJavascript.txt
< prev
next >
Wrap
Text File
|
2006-08-04
|
2KB
|
64 lines
// Based on some code fragments at:
// http://www.codecomments.com/JScript/message294790.html
// Use like this: boundsOfObject(document.getElementById("k-26FF13A42F7911D9B573"))
function boundsOfObject(aElm)
{
if (!aElm) return false;
var x = aElm.offsetLeft;
var y = aElm.offsetTop;
var w = aElm.offsetWidth;
var h = aElm.offsetHeight;
// WHEN DO I NEED TO, OR NOT NEED TO, TRAVERSE THE PARENTS....
var lParent = aElm.parentNode;
var log = aElm + " : " + x + "," + y + " ... ";
while (lParent && typeof lParent.offsetLeft != "undefined") {
log = log + " parent : " + lParent + " : " + lParent.offsetLeft + ", " + lParent.offsetTop + "; ";
x += lParent.offsetLeft;
y += lParent.offsetTop;
lParent = lParent.offsetParent;
}
return x + "," + y + "," + w + "," + h + " " + log;
}
// Get border of element and set to special highlighted state
function activateHilite(aElm)
{
if (!aElm) return;
aElm.style.border = '2px ridge #6badef';
aElm.style.margin = '-2px';
}
// Take out border, de-hiliting.
function deactivateHilite(aElm)
{
if (!aElm) return;
aElm.style.border = 'none';
aElm.style.margin = '0';
}
// Based on code fragments at:
// http://www.codelifter.com/main/javascript/capturemouseposition1.html
// Returns the scroll position (relative to top,left)
function scrollOffset()
{
var dx = document.body.scrollLeft;
var dy = document.body.scrollTop;
return dx + "," + dy;
}
function viewSize()
{
var x = document.body.clientWidth;
var y = document.body.clientHeight;
return x + "," + y;
}
// Mouse position: see
// http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/?format=print